/**
 * TUTORIAL: http://www.juergenwiki.de/work/wiki/doku.php?id=public:gabor_filter
 */

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <math.h>

int main(int argc, char** argv)
{
    cv::Mat image = cv::imread("01_3d_min2.bmp",1);

    cv::imshow("Src", image);
    cv::Mat src, src2;
    cv::cvtColor(image, src, CV_BGR2GRAY);
    cv::cvtColor(image, src2, CV_BGR2GRAY);


    //*************************************************************
    	const uchar THERESHOLD = 140;
    	//just a thereshold
    	for (int i = 0; i < src.rows; ++i) {
    		uchar *cur_row = src.ptr(i);
    		for (int j = 0; j < src.cols; ++j) {
    			if (cur_row[j] < THERESHOLD) {
    				cur_row[j] = 0;
    			}
    		}
    	}
    	cv::GaussianBlur(src,src,cv::Size(3,3),0,0);
    //*************************************************************

    cv::imshow("Src Primaria", src);


    //*************************************************************
        	const uchar THERESHOLD2 = 100;
        	//just a thereshold
        	for (int i = 0; i < src2.rows; ++i) {
        		uchar *cur_row = src2.ptr(i);
        		for (int j = 0; j < src2.cols; ++j) {
        			if (cur_row[j] > THERESHOLD || cur_row[j] < THERESHOLD2) {
        				cur_row[j] = 0;
        			}
        		}
        	}
        	cv::GaussianBlur(src,src,cv::Size(3,3),0,0);
        //*************************************************************

            cv::imshow("Src Secondaria", src2);

    cv::waitKey(0);
    return 0;
}

